# coding: utf-8
import allure
from page.base.BasePage import BasePage
from selenium.webdriver.common.by import By


class LoginPage(BasePage):
    __username_input = (By.ID, "com.xx.xxxxx:id/edit_user_name")
    __password_input = (By.ID, "com.xx.xxxxx:id/edit_password")
    __login_button = (By.ID, "com.xx.xxxxx:id/btn_login")

    # 密码登录操作
    @allure.step("输入用户名：{username}，输入密码：{password}")
    def login_action(self, username, password):
        self.log.info("开始执行登录操作……")
        self.log.info("用户名：%s" %username)
        self.driver.find_element(*self.__username_input).send_keys(username)
        self.log.info("密码：%s" %password)
        self.driver.find_element(*self.__password_input).send_keys(password)
        self.log.info("点击登录！")
        self.driver.find_element(*self.__login_button).click()